{extend name="common:base" /}
{block name="body"}
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form">
            <input type="hidden" id="id" name="id" value="{$data.id}">
            <div class="layui-form-item">
                <label for="type" class="layui-form-label">
                    <span class="x-red">*</span>类型
                </label>
                <div class="layui-input-inline">
                    <select name="type" lay-verify="required" id="type">
                        <option value="{$data.type}">{$data.value}</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="listorder" class="layui-form-label">
                    <span class="x-red">*</span>排序
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="listorder" name="listorder" required="" lay-verify="required"
                        autocomplete="off" class="layui-input" value="{$data.listorder}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="image" class="layui-form-label">
                    <span class="x-red">*</span>桌面端
                </label>
                <div class="layui-input-inline">
                    <button class="layui-btn" type="button"
                        onclick="xadmin.open('选择图片','{:url(\'media_select_image\',[\'path\'=>\'images\/\',\'class\'=>\'desktop\'])}')">
                        <i class="layui-icon"></i>选择图片</button>
                    <div class="desktop" style="height: 92px;padding-top: 5px">
                        <img src="{$data.desktop}" alt="" style="height: 92px">
                        <input type="hidden" name="desktop" value="{$data.desktop}" id="desktop">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="image" class="layui-form-label">
                    <span class="x-red">*</span>移动端
                </label>
                <div class="layui-input-inline">
                    <button class="layui-btn" type="button"
                        onclick="xadmin.open('选择图片','{:url(\'media_select_image\',[\'path\'=>\'images\/\',\'class\'=>\'mobile\'])}')">
                        <i class="layui-icon"></i>选择
                    </button>
                    <div class="mobile" style="height: 92px;padding-top: 5px">
                        <img src="{$data.mobile}" alt="" style="height: 92px">
                        <input type="hidden" name="mobile" value="{$data.mobile}" id="mobile">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="title" class="layui-form-label">
                    标题
                </label>
                <div class="layui-input-block" style="width: 50%">
                    <input type="text" id="title" name="title" required="" autocomplete="off" class="layui-input"
                        value="{$data.title}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="description" class="layui-form-label">
                    描述
                </label>
                <div class="layui-input-block" style="width: 50%">
                    <textarea name="description" id="description" placeholder="请输入内容"
                        class="layui-textarea">{$data.description}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="button" class="layui-form-label">
                    按钮文案
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="button" name="button" required="" autocomplete="off" class="layui-input"
                        value="{$data.button}">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="path" class="layui-form-label">
                    指向链接
                </label>
                <div class="layui-input-block" style="width: 50%">
                    <input type="text" id="path" name="path" required="" autocomplete="off" class="layui-input"
                        value="{$data.path}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                </label>
                <button class="layui-btn" lay-filter="add" lay-submit="">
                    保存
                </button>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="copyright"}
{/block}
{block name="javascript"}
<script>
    layui.use(['form', 'layer'],
        function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            //监听提交
            form.on('submit(add)',
                function (data) {
                    $.ajax({
                        url: "{:url('content_edit_pretties')}",
                        type: 'POST',
                        data: data.field,
                        'success': function (result) {
                            if (result.status === 1) {
                                layer.msg(result.message, { 'icon': 1, 'time': 1000 }, function () {
                                    xadmin.close();
                                    xadmin.father_reload();
                                });
                            } else {
                                layer.msg(result.message, { 'icon': 5, 'time': 8000 });
                            }
                        }
                    }, 'JSON');
                    return false;
                });

        });
</script>
{/block}